package com.itheima.SmartHome;

public class SmartControl
{
    //设置为单例类
    private static final SmartControl sc=new SmartControl();
    public static final SmartControl getInstance()
    {
        return sc;
    }
    //控制开关
    public  void control(JD jd)
    {
        System.out.println("之前的开关状态是："+(jd.isPower()?"开":"关"));
        jd.push();
        System.out.println("现在的开关状态是："+jd.isPower());
    }
    //打印所有状态
    public void printAll(JD[]jds)
    {
        for(int i=0;i<jds.length;i++)
        {
            System.out.println(i+1+"."+jds[i].getName()+"开关状态是："+(jds[i].isPower()?"开":"关"));
        }
    }
}
